package cc.zy.base.hr.service.impl;

import cc.zy.base.common.entity.FebsConstant;
import cc.zy.base.common.entity.QueryRequest;
import cc.zy.base.common.utils.SortUtil;
import cc.zy.base.hr.entity.Lecturer;
import cc.zy.base.hr.mapper.InsideTeacherMapper;
import cc.zy.base.hr.mapper.OutsideTeacherMapper;
import cc.zy.base.hr.service.IInsideTeacherService;
import cc.zy.base.hr.service.IOutsideTeacherService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 院校
 * Service
 *
 * @author Jiangjinlin
 * @date 2021-01-18 10:51:13
 */
@Service
@RequiredArgsConstructor
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class InsideTeacherServiceImpl extends ServiceImpl<InsideTeacherMapper, Lecturer> implements IInsideTeacherService {

    @Resource
    private final InsideTeacherMapper insideTeacherMapper;

    /**
    * @Author: PW
    * @Description: 
    * @DateTime: 2022/3/8 22:20
    * @Params: [request, outsideTeacher]
    * @Return com.baomidou.mybatisplus.core.metadata.IPage<cc.zy.base.hr.entity.OutsideTeacher>
    */
    @Override
    public IPage<Lecturer> listInsideTeacherDetailPage(QueryRequest request, Lecturer lecturer) {
        Page<Lecturer> page = new Page<>(request.getPageNum(), request.getPageSize());
        page.setSearchCount(false);
        page.setTotal(insideTeacherMapper.countInsideTeacherDetail(lecturer));
        SortUtil.handlePageSort(request, page, "id", FebsConstant.ORDER_ASC, false);
        return insideTeacherMapper.listInsideTeacherDetailPage(page, lecturer);
    }
}
